package com.fg.ihr.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fg.ihr.domain.Department;
import com.fg.ihr.domain.Education;
import com.fg.ihr.repository.DepartmentRepository;
import com.fg.ihr.repository.EducationRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/education")
public class EducationController {
    private static final Logger logger = LoggerFactory.getLogger(EducationController.class);

    @Autowired
    EducationRepository educationRepository;
    @GetMapping("/list")
    @ResponseBody
    public String getEduList(
    ){
        List<Education> result = educationRepository.findAll();
        JSONArray list = JSONObject.parseArray(JSON.toJSONString(result));
        String edus = JSON.toJSONString(list);
        return edus;
    }
}
